home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / libelf-0.5 / libelf-0 / libelf-0.5.2 / 32.fsize.c next >
Encoding:
C/C++ Source or Header  |  1995-10-19  |  2.0 KB  |  60 lines

  1. /*
  2. 32.fsize.c - implementation of the elf32_fsize(3) function.
  3. Copyright (C) 1995 Michael Riepe <riepe@ifwsn4.ifw.uni-hannover.de>
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19.  
  20. #include <private.h>
  21. #include <ext_types.h>
  22.  
  23. const size_t
  24. _elf32_fmsize[EV_CURRENT - EV_NONE][ELF_T_NUM][2] = {
  25.     {
  26.     { sizeof(unsigned char),    sizeof(unsigned char)    },
  27.     { sizeof(Elf32_Addr),        sizeof(__ext_Elf32_Addr)    },
  28.     { sizeof(Elf32_Dyn),        sizeof(__ext_Elf32_Dyn)    },
  29.     { sizeof(Elf32_Ehdr),        sizeof(__ext_Elf32_Ehdr)    },
  30.     { sizeof(Elf32_Half),        sizeof(__ext_Elf32_Half)    },
  31.     { sizeof(Elf32_Off),        sizeof(__ext_Elf32_Off)    },
  32.     { sizeof(Elf32_Phdr),        sizeof(__ext_Elf32_Phdr)    },
  33.     { sizeof(Elf32_Rela),        sizeof(__ext_Elf32_Rela)    },
  34.     { sizeof(Elf32_Rel),        sizeof(__ext_Elf32_Rel)    },
  35.     { sizeof(Elf32_Shdr),        sizeof(__ext_Elf32_Shdr)    },
  36.     { sizeof(Elf32_Sword),        sizeof(__ext_Elf32_Sword)    },
  37.     { sizeof(Elf32_Sym),        sizeof(__ext_Elf32_Sym)    },
  38.     { sizeof(Elf32_Word),        sizeof(__ext_Elf32_Word)    },
  39.     },
  40. };
  41.  
  42. size_t
  43. elf32_fsize(Elf_Type type, size_t count, unsigned ver) {
  44.     size_t n;
  45.  
  46.     if (!valid_version(ver)) {
  47.     seterr(ERROR_UNKNOWN_VERSION);
  48.     }
  49.     else if (!valid_type(type)) {
  50.     seterr(ERROR_UNKNOWN_TYPE);
  51.     }
  52.     else if (!(n = _fsize32(ver, type))) {
  53.     seterr(ERROR_UNKNOWN_TYPE);
  54.     }
  55.     else if (count) {
  56.     return count * n;
  57.     }
  58.     return 0;
  59. }
  60.